package com.jeesite.modules.digitalize.controller;


import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.modules.digitalize.entity.DigitalizeComponentIntegration;
import com.jeesite.modules.digitalize.entity.dto.DigitalizeComponentIntegrationDTO;
import com.jeesite.modules.digitalize.entity.dto.DigitalizeComponentIntegrationQueryDTO;
import com.jeesite.modules.digitalize.entity.dto.system.reviewproces.DeleteIdListDTO;
import com.jeesite.modules.digitalize.service.DigitalizeComponentIntegrationService;
import com.jeesite.modules.digitalize.util.response.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@Api(tags = "数字-模型集成 相关功能")
@RequestMapping("${adminPath}/digitalize/integration")
public class DigitalizeComponentIntegrationController extends ApiController {

    /**
     * 服务对象
     */
    @Resource
    private DigitalizeComponentIntegrationService digitalizeComponentIntegrationService;

    /**
     * @date 2024年01月03日 15:17:54
     * @author patronli
     * @Description: 新建集成
     */
    @ApiOperation("新建集成")
    @PostMapping("/add")
    public ResultVo add(@RequestBody DigitalizeComponentIntegrationDTO dto) {
        return digitalizeComponentIntegrationService.add(dto);
    }
    /**
     * @date 2024年01月03日 15:18:24
     * @author patronli
     * @Description: 集成模型列表
     */
    @ApiOperation("集成模型列表")
    @GetMapping("/pageList")
    public ResultVo<Page<DigitalizeComponentIntegration>> pageList(@Validated DigitalizeComponentIntegrationQueryDTO dto) {
        Page<DigitalizeComponentIntegration> page = new Page<>(dto.getPageNo(), dto.getPageSize());
        return ResultVo.success(this.digitalizeComponentIntegrationService.lambdaQuery().
                like(StringUtils.isNotBlank(dto.getIntegrateName()),
                        DigitalizeComponentIntegration::getIntegrateName, dto.getIntegrateName())
                .eq(DigitalizeComponentIntegration::getProjectCode, dto.getProjectCode()).page(page));
    }
    /**
     * @date 2024年01月03日 15:18:43
     * @author patronli
     * @Description: 删除集成 支持批量
     */
    @ApiOperation("删除数据")
    @PostMapping("/delete")
    public ResultVo deleteList(@RequestBody DeleteIdListDTO dto) {
        return this.digitalizeComponentIntegrationService.removeRecycleByIds(dto.getIdList());
    }

}

